import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  optimizeDeps: {
    include: ['@/lib/vform/designer.umd.js']  //此处路径必须跟main.js中import路径完全一致！
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@use "@/styles/_variables.scss" as *;'
      }
    }
  },
  //代理跨域
  server: {
    proxy: {
      '/dev-api': {
        //获取数据的服务器地址设置
        target: 'http://localhost:9527',
        //需要代理跨域
        changeOrigin: true,
        //路径重写
        rewrite: (path) => path.replace(/^\/dev-api/, ''),
      },
    },
  },
})
